<%@page import="abservlet.ALLServlet"%>
<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8"%>
<%@ page import="bean.StudentInfo"%>
<%@ page import="bean.page"%>
<%
	String path=request.getContextPath();
    String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>学生信息</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="catch-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="Content-Type" content="text/css; charset=UTF-8">
<script type="text/javascript">
	function confirmdialog() {
		if (window.confirm("您确定要删除此条信息？")) {
			return true;
		} else {
			alert("取消删除！")
			return flase;
		}
	}
</script>
</head>
<body>
	<br>
	<h1>学生信息</h1>
	<br>
	<hr>
	<br>
	<h3>全部学生信息如下</h3>
	<table width="510" border="100" cellSpacing=1
		style="border: 1pt dashed; font-size: 15pt;" heigtht="31">
		<tr>
			<td>学号</td>
			<td>姓名</td>
			<td>年龄</td>
			<td>性别</td>
			<td>专业</td>
		</tr>
		<%
			response.setCharacterEncoding("UTF-8");
			request.setCharacterEncoding("UTF-8");
			page pager = (page) request.getAttribute("pager");
			List<StudentInfo> subResult = (List<StudentInfo>) request.getAttribute("subResult");
			if (!subResult.isEmpty()) {
				for (int i = 0; i < subResult.size(); i++) {
					StudentInfo st = subResult.get(i);
					out.print("<tr>");
					out.print("<td>" + st.getId() + "</td>");
					out.print("<td>" + st.getName() + "</td>");
					out.print("<td>" + st.getAge() + "</td>");
					out.print("<td>" + st.getGender() + "</td>");
					out.print("<td>" + st.getMajor() + "</td>");
					out.print("</tr>");
		%>
		<td><a href="ALLServlet?id=<%=st.getId()%>&methodName=<%=2%>"
			onclick="return comfirmdialog()">删除</a></td>
		<td><a
			href="ALLServlet?id=<%=st.getId()%>&name=<%=""%>&methodName=<%=4%>">修改</a></td>

		<%
			out.print("</tr>");

				}
			}
		%>
	</table>
	<span><font size="2">总<%=pager.getTotalRecord()%>条记录 <%=pager.getTotallPage()%>页
			<%=pager.getCurrentPage() + 1%>页<%=pager.getPageSize()%>条 <%
		int last = pager.getCurrentRecord() - pager.getPageSize();
		int next = pager.getCurrentRecord() + pager.getPageSize();
		int CurrentRecord;
		if (last < 0) {
			out.println("首页");
		} else {
			out.print("<a href='ALLServlet?currentRecord=" + last
					+ "&methodName=1'>上一页</a>");
		}
		if (next >= pager.getTotalRecord()) {
			out.println("尾页");
		} else {
			out.print("<a href='ALLServlet?)currentRecord=" + next
					+ "&methodName= '>下一页</a>'");
		}
	%>


	</font></span>
	<br>
	<form action="ALLServlet" method="post">
		<input type="hidden" name="methodName" value="5" />
		<h3>按学号姓名查询：</h3>
		学号：<input type="text" name="id" value="" title="学号必须为数字"></input> 姓名：<input
			type="text" name="name" value="" title=" "></input> <input
			type="submit" value="查询" />
	</form>
	<br>
	<h3>
		<a href="putin.jsp">返回信息输入页面</a>
	</h3>
	<br>
</body>
</html>